﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <Header>
    <Title>AddRowNo</Title>
    <Author>jinlei</Author>
    <Shortcut>AddRowNo</Shortcut>
    <Description>给DataGridView添加行号</Description>
    <SnippetTypes>
      <SnippetType>SurroundsWith</SnippetType>
      <SnippetType>Expansion</SnippetType>
    </SnippetTypes>
  </Header>
  <Snippet>
    <Declarations>
      <Literal>
        <ID>名称</ID>
        <Default>值</Default>
      </Literal>
    </Declarations>
    <Code Language="CSharp">
      <![CDATA[var gv = sender as ComponentFactory.Krypton.Toolkit.KryptonDataGridView;
            if (gv == null)
                return;
      System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X,
                        e.RowBounds.Location.Y,
                        gv.RowHeadersWidth - 4,
                        e.RowBounds.Height);

            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                gv.RowHeadersDefaultCellStyle.Font,
                rectangle,
                gv.RowHeadersDefaultCellStyle.ForeColor,
                TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
      ]]>
    </Code>
  </Snippet>
</CodeSnippet>